package com.example.asapp.demo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import lombok.extern.slf4j.Slf4j;

import java.io.StringWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import org.springframework.web.bind.annotation.GetMapping;

@RestController
@Slf4j
@RequestMapping("demo")
public class DemoApi {

    @Autowired
    DemoDao demoDao;

    @PostMapping
    public Demo add(@RequestBody Demo Demo){
        Demo.setId(UUID.randomUUID().toString());
        return demoDao.save(Demo);
    }

    @PutMapping
    public Demo update(@RequestBody Demo Demo){
        return demoDao.save(Demo);
    }
    @DeleteMapping("{id}")
    public void delete(@PathVariable String id){
        demoDao.deleteById(id);
    }

}
